<template>
  <div>
    <ul>

      <li v-for='i in resourcelist' :key='i.name'>
        <router-link :to="{'path':i.url}">{{i.name}}</router-link>
      </li>
    </ul>


  </div>
</template>

<script>
import {reactive} from 'vue'
export default {
  setup() {
    let customerlist = reactive({'data':[{'name':'234'}]})
    let userid = localStorage.getItem('uid')

    //初始化websocket
    const initWebsocket=()=>{
      let socket = new WebSocket('ws://127.0.0.1:8000/web_conn/'+userid)
      //建立
      socket.onopen=function(){
        console.log('建立连接')
      }
      //接收消息
      socket.onmessage=function(msg){
        console.log(msg.data)
        // customerlist.data=JSON.parse(msg.data)
      }
      //关闭
      socket.close=function(e){
        console.log(e)
        console.log('close')
      }
    }


    return{
      customerlist,
      initWebsocket
    }
  },
  name: "menu",
  data() {
    return {
      data1: '',
      resourcelist:JSON.parse(localStorage.getItem('resourcelist'))

    }
  },
  methods: {},
  mounted() {
    this.initWebsocket()
  }
}
</script>

<style scoped>

</style>